import {defineStore} from 'pinia'
import api from '@/api'
import dynicRoute from '@/utils/dynicRoute'

const useAuthStore=defineStore("auth",{
    state(){
        return{
            authMenus:JSON.parse(localStorage.getItem("authMenus")!)||[]
        }
    },
    actions:{
        async getAuthMenuAsync(){
           const result=await api.loginModule.getAuthMenusApi()
           this.authMenus=result.data.data
           localStorage.setItem("authMenus",JSON.stringify(result.data.data)) 
        },
        async generatorRouteAsync(){
            const result=await api.loginModule.getAuthMenusApi()
            dynicRoute(result.data.data)
            
        }
    }
})
export default useAuthStore